<script setup lang="ts">
import { getBrowserLang } from '@/utils'
import { GlobalStore } from '@/store/index'
import { useTheme } from '@/hooks/useTheme'
import zhCn from 'element-plus/lib/locale/lang/zh-cn'
import en from 'element-plus/es/locale/lang/en'
const settingsStore = GlobalStore()
const themeConfig = computed(() => settingsStore.themeConfig)

// 配置element按钮文字中间是否有空格
const config = reactive({
  autoInsertSpace: false,
})
// 获取全局组件大小
const getGlobalComponentSize = computed(() => {
  console.log('themeConfig.value.globalComponentSize', themeConfig.value.globalComponentSize)
  return themeConfig.value.globalComponentSize
})
// element language
const i18nLocale = computed(() => {
  if (settingsStore.language === 'zh') return zhCn
  if (settingsStore.language === 'en') return en
  return getBrowserLang() === 'zh' ? zhCn : en
})
// 初始化主题
const { initTheme } = useTheme()
initTheme()
</script>

<template>
  <el-config-provider :size="getGlobalComponentSize" :locale="i18nLocale" :button="config">
    <router-view></router-view>
  </el-config-provider>
</template>

<style scoped>
.logo {
  height: 6em;
  padding: 1.5em;
  will-change: filter;
  transition: filter 300ms;
}

.logo:hover {
  filter: drop-shadow(0 0 2em #646cffaa);
}

.logo.vue:hover {
  filter: drop-shadow(0 0 2em #42b883aa);
}
</style>
